﻿@{
    ViewBag.Title = "RoleList";
    Layout = "~/Views/Shared/_Main.cshtml";
}
<script type="text/javascript">
    function ButtonSearch() {
        var v = $("#txtCompany").val();
        var n = $("#txtStatus").val();
        var d = $("#txtDB").val();
        $("#DataGrid").datagrid({
            url: "/SysRole/RoleList/?name=" + encodeURI(v) + "&statusStr=" + encodeURI(n) + "&dbName=" + encodeURI(d)
            , pageNumber: 1
        });
    }
    function AddItem() {
        window.location.href = "/SysRole/RoleEdit";
    }
    function Edit(v) {
        window.location.href = "/SysRole/RoleEdit/?id=" + v;
    }
    function User(v) {
        window.location.href = "/SysRole/RoleUser/?id=" + v;
    }
    function Competence(v) {
        window.location.href = "/SysRole/Competence/?id=" + v;
    }
    function Targat(v) {
        window.location.href = "/SysRole/RoleTarge/?id=" + v;
    }

    function DeleteItem(v) {
        $.post("/SysRole/DeleteItem/?id=" + v);
        $("#DataGrid").datagrid({
            url: "/SysRole/RoleList"
        });
    }
    function UpStatus(v, s) {
        $.post("/SysRole/UpdateState/?id=" + v + "&status=" + s);
        $("#DataGrid").datagrid({
            url: "/SysRole/RoleList"
        });
    }
    $(function () {
        $("#DataGrid").datagrid({
            width: 800,
            height: 480,
            autoRowHeight: false,
            fitColumns: true,
            pagination: true,
            rownumbers: true,
            striped: true,
            pageList: [10, 15, 20, 25, 30],
            pageSize: 15,
            title: '角色列表',
            iconCls: 'icon-save',
            url: "/SysRole/RoleList",
            columns: [[
                { field: 'Code', title: '编码', width: 200 },
                { field: 'Name', title: '角色名称', width: 230 },
                { field: 'DBName', title: '数据库名称', width: 150 },
               { field: 'Status', title: '状态', align: 'center', width: 50, formatter: function (value, rowData, rowIndex) {
                   if (value == 1)
                       return "启用";
                   if (value == 2)
                       return "<span class='grid_r'>禁用</span>";
               }
               },

                { field: 'Id', title: '操作', width: 200, align: 'center', formatter: function (value, rowData, rowIndex) {
                    if ($("#MDM_RoleID").val() == "3370c724-23d9-41a1-a281-6e4ccff478eb") {
                        if (rowData.Code == "SA01" || rowData.Code == "A01")
                            return ""
                        else
                            return "<a onclick='User(\"" + value + "\");' class='grid_a'>查看分组用户</a>";
                    }
                    else
                        return "<a onclick='Competence(\"" + value + "\");' class='grid_a'>分组权限配置</a>&nbsp;|&nbsp;<a onclick='User(\"" + value + "\");' class='grid_a'>查看分组用户</a>";
                }
                }
            ]]
        });
    }); 
</script>
<div style="margin: 5px;">
    <div class="easyui-panel" style="width: 800px;" data-options="title:'角色列表搜索',iconCls:'icon-search'">
        <table>
            <tr>
                <td>
                    <input type="hidden" id="MDM_RoleID" value="@Request.Cookies["MDM_RoleID"].Value" />
                    角色名称：
                    <input id="txtCompany" type="text" class="inputSearch" style="width: 160px;" />
                    状态：
                    <select id="txtStatus" name="txt_Status">
                        <option value="0">请选择</option>
                        <option value="2">禁用</option>
                        <option value="1">启用</option>
                    </select>
                    数据库名称：
                    <input id="txtDB" type="text" class="inputSearch" style="width: 160px;" />
                    <input id="buttonSearch" type="button" value=" 搜索 " onclick="ButtonSearch()" />
                </td>
            </tr>
        </table>
    </div>
</div>
<div style="margin-left: 5px;">
    <table id="DataGrid">
    </table>
</div>
